/*  J2EE COE Left Hand Menu Widget, version X.X.X
 *  (c) 2005 Ford Motor Company
 *
/*--------------------------------------------------------------------------*/

function leftNavBar_Init() {
	if (document.getElementById && document.getElementsByTagName && document.createTextNode) {
		var elCompleteMenu = document.getElementById('leftnavbar');
		//var elSubHeaders = leftNavBar_GetElementsByClass('leftnavbar_subhead');
		var elSubHeadersLi = elCompleteMenu.getElementsByTagName('LI');
		for (var i = 0; i < elSubHeadersLi.length; i++) {
			
			//Determines contents of subhead span tag
			//elSubHeaderContents = elSubHeaders[i].firstChild.nodeValue;
			
			//Collapse lists under subheads
			//elSubHeaderLi = elSubHeaders[i].parentNode;
			var elSubHeaderSubLi = elSubHeadersLi[i].getElementsByTagName('LI');
			var currentBelongsToSection = 0;
			var currentParsedIsCurrent = 0;
			var parsedHasSubPics = 0;
			
			if (elSubHeadersLi[i].className == 'leftnavbar_current') {
				currentParsedIsCurrent = 1
			}
			if (elSubHeaderSubLi.length >= 1) {
				parsedHasSubPics = 1;
			}
			for (var k = 0; k < elSubHeaderSubLi.length; k++) {
				if(elSubHeaderSubLi[k].className == 'leftnavbar_current') {
					currentBelongsToSection = 1;
				}
			}
			if(currentBelongsToSection == 1) {
				elSubHeadersLi[i].className = "leftnavbar_expanded leftnavbar_currentsection";
			}
			if(currentParsedIsCurrent == 1) {
				if(parsedHasSubPics == 1) {
					elSubHeadersLi[i].className = "leftnavbar_current leftnavbar_expanded leftnavbar_currentsection";
				} else {
					elSubHeadersLi[i].className = "leftnavbar_current";
				}
			}
			if((currentParsedIsCurrent == 0)&&(currentBelongsToSection == 0)&&(parsedHasSubPics == 1)) {
				elSubHeadersLi[i].className = "leftnavbar_collapsed";
			}			
			
		} // end of for
	} // end of if
} // end of function

function leftNavBar_ExpandCollapse(whichSubhead) {
	elParentLi = whichSubhead.parentNode;
	if(elParentLi.className == 'leftnavbar_expanded leftnavbar_currentsection') {
		elParentLi.className = 'leftnavbar_collapsed leftnavbar_currentsection';
	} else if(elParentLi.className == 'leftnavbar_collapsed leftnavbar_currentsection') {
		elParentLi.className = 'leftnavbar_expanded leftnavbar_currentsection'
	} else if(elParentLi.className == 'leftnavbar_expanded') {
		elParentLi.className = 'leftnavbar_collapsed'
	} else if(elParentLi.className == 'leftnavbar_collapsed') {
		elParentLi.className = 'leftnavbar_expanded'
	}
} // end of function

function leftNavBar_GetElementsByClass(theClass) {
	var elCompleteMenu = document.getElementById('leftnavbar');
	var gotCollection = new Array();
	var gotAll = new Array();
	gotAll = elCompleteMenu.getElementsByTagName("*");
    j=0;
    for (i=0; i<gotAll.length; i++) {
	   if ((gotAll[i].className==theClass)||(gotAll[i].className.search(" " + theClass)!=-1)||(gotAll[i].className.search(" " + theClass + " ")!=-1)||(gotAll[i].className.search(theClass + " ")!=-1)) {
			gotCollection[j]=gotAll[i];
			j++;
	   }
	}
    return gotCollection;
}

window.onload = leftNavBar_Init;